package com.lh.lepay.controller;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.CircleCaptcha;
import com.lh.lepay.entity.SysUser;
import com.lh.lepay.service.SysUserService;
import com.lh.lepay.utils.ResponseData;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author liuzongyi ~ Mr.Liu
 * @week 星期二
 * @address https://github.com/liu17y
 * @since 2024/6/11~~13:52
 */
@RestController
@RequestMapping("/user")
public class SysUserController {

    @Resource
    private SysUserService userService;

//    @Resource
//    private EmailService emailService;

    @PostMapping("/login")
    public ResponseData login(@RequestBody SysUser sysUser){
        return userService.UserLoginByUsernameAndPassword(sysUser);
    }

    @RequestMapping("/logout")
    public ResponseData logoutUser(){
        return userService.logout();
    }


//    /**
//     * 发送邮件验证码
//     * @param email
//     * @return
//     */
//    @RequestMapping("/email/{email}")
//    public Result sendEmailCode(@PathVariable("email") String email){
//        return emailService.sendEmail(email);
//    }
//
//    @RequestMapping("/phone/{phoneNumber}")
//    public Result sendPhoneCode(@PathVariable("phoneNumber") String phoneNumber){
//        return loginService.sendPhoneCode(phoneNumber);
//    }
//
//
//    @RequestMapping("/verificationCode")
//    public ResponseResult register(){
//        CircleCaptcha circleCaptcha = CaptchaUtil.createCircleCaptcha(100, 40, 5, 20);
//        String code = circleCaptcha.getCode();
//        System.out.println(code);
//        String image = circleCaptcha.getImageBase64Data();
//        return new ResponseResult(200,"验证码发送成功",image);
//    }
}
